import java.util.HashSet;

public class text1 {
    public static String solve (String str) {

        char[]ch=str.toCharArray();
        int left=0;
        int right=ch.length-1;
        while(left<right)
        {
              char tmp=ch[left];
              ch[left]=ch[right];
              ch[right]=tmp;
            left++;
            right--;
        }
        return new String(ch);

        // write code here
    }

    public static int maxLength (int[] arr) {
        int i=0;
        int j=0;
        int max=1;
        int m=1;
        HashSet<Integer> b=new HashSet<>();
        while(i<arr.length)
        {
            m=1;
            j=i+1;
            b.add(arr[i]);
            while(j<arr.length)
            {
                if(b.contains(arr[j]))
                {

                    b.clear();
                    break;

                }
                else
                {
                    m++;
                    b.add(arr[j]);
                    j++;
                }
            }
            if(m>max)
            {
                max=m;
            }
            if(max==arr.length)
            {
                return arr.length;
            }
            i++;


        }
        return max;
        // write code here
    }
    public static String trans(String s, int n) {
        int i=0;
        for(i=0;i<s.length();i++)
        {
            char ch=s.charAt(i);
            if(ch>='a'&&ch<='z')
            {

                ch=(char)(ch-32);


            }
            else if(ch>='A'&&ch<='Z')
            {
                ch=(char)(ch+32);


            }
        }
        char[]arr=s.toCharArray();
        int start=0;
        int end=0;
        i=0;
        while(i<arr.length)
        {

            while(i<arr.length&&arr[i]!=' ')
            {
                i++;
            }
            end=i-1;


            swop(arr,start,end);
            start=end+2;
            i++;
        }
        swop(arr,0,arr.length-1);
        return new String(arr);
    }
    public static void swop(char[]arr,int start,int end)
    {
        while(start<=end)
        {
            char tmp=arr[start];
            arr[start]=arr[end];
            arr[end]=tmp;
            start++;
            end--;

        }

    }

    public static void main(String[] args) {
        String str="abcd";
        String b=solve(str);
        System.out.println(b);
    }


    public static void main2(String[] args) {
        int[]arr={2,3,4,5};
        int b=maxLength(arr);
        System.out.println(b);

    }
    public static void main1(String[] args) {
        String a="This is a sample";



        String b=trans(a,16);
        System.out.println(b);


    }
}
